/* build info:
   ASTUce : ActionScript Test Unit compact edition v1.0.0 for Flash 6
   Mon Dec 12 2005 07:42:16 GMT+0100
*/
/*
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at 
http://www.mozilla.org/MPL/ 
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License. 
The Original Code is ASTUce: ActionScript Test Unit compact edition. 
The Initial Developer of the Original Code is
Zwetan Kjukov <zwetan@gmail.com>.
Portions created by the Initial Developer are Copyright (C) 2004-2005
the Initial Developer. All Rights Reserved.
Contributor(s):
*/
if( !_global.hasOwnProperty( "buRRRn" ) )
{
_global.buRRRn = {};
}
if( !buRRRn.ASTUce  )
{
buRRRn.ASTUce = {};
}
buRRRn.ASTUce.getInfo = function()
{
var str, CRLF;
str = "";
CRLF = "\n";
if( this.verbose )
{
str += this._name + ": " + this._fullName + " v" + this._version;
}
else
{
str += this._name + " v" + this._version;
}
if( this.verbose )
{
str += CRLF;
str += "Copyright (c) 2004-2005 Zwetan Kjukov, All right reserved." +CRLF
str += "Made in the EU.";
}
return str;
}
buRRRn.ASTUce.main = function()
{
var separator = "----------------------------------------------------------------";
trace( separator );
var runner = new buRRRn.ASTUce.MiniRunner( "Main Tests" );
if( this.testMyself )
{
runner.setUp = function()
{
this.suite.addTest( Tests.AllTests.suite() );
}
}
if( arguments.length > 0 )
{
for( var i=0; i<arguments.length; i++ )
{
runner.suite.addTest( arguments[i] );
}
}
trace( this.getInfo() );
trace( separator );
runner.run();
trace( separator );
if( this.showConstructorList )
{
trace( runner.suite );
trace( separator );
}
}
buRRRn.ASTUce._name = "ASTUce";
buRRRn.ASTUce._fullName = "ActionScript Test Unit compact edition";
buRRRn.ASTUce._version = "1.0.0";
buRRRn.ASTUce._platform = "Flash 6";
buRRRn.ASTUce.Assertion = {};
buRRRn.ASTUce.Assertion.assertTrue = function(  condition,  message )
{
if( !condition )
{
this.fail( message );
}
}
buRRRn.ASTUce.Assertion.assertFalse = function(  condition,  message )
{
this.assertTrue( !condition, message );
}
buRRRn.ASTUce.Assertion.assertEquals = function( expected, actual,  message )
{
if( (expected == null) && (actual == null) )
{
return;
}
if( (expected != null) && expected.equals( actual ) ) 
{
return;
}
if( ( GetTypeOf( expected ) == "string" ) || ( GetTypeOf( actual ) == "string" ) ) 
{
this.__e = new buRRRn.ASTUce.ComparisonFailure( expected, actual, message );
}
else
{
this._failNotEquals( expected, actual, message );
}
}
buRRRn.ASTUce.Assertion.assertNotNull = function( obj,  message )
{
this.assertTrue( obj != null, message );
}
buRRRn.ASTUce.Assertion.assertNull = function( obj,  message )
{
this.assertTrue( obj == null, message );
}
buRRRn.ASTUce.Assertion.assertUndefined = function( obj,  message )
{
this.assertTrue( obj == undefined, message );
}
buRRRn.ASTUce.Assertion.assertNotUndefined = function( obj,  message )
{
this.assertTrue( obj != undefined, message );
}
buRRRn.ASTUce.Assertion.assertSame = function( expected, actual,  message )
{
if( expected == null )
		{
		expected = new NullObject(); 
		}
if( expected.referenceEquals( actual ) ) 
{
return;
}
this._failNotSame( expected, actual, message );
}
buRRRn.ASTUce.Assertion.assertNotSame = function( expected, actual,  message )
{
if( expected == null )
		{
		expected = new NullObject(); 
		}
if( expected.referenceEquals( actual ).toBoolean() ) 
{
this._failSame( expected, actual, message );
}
}
buRRRn.ASTUce.Assertion.fail = function(  message )
{
this.__e = new buRRRn.ASTUce.AssertionFailedError( message );
}
buRRRn.ASTUce.Assertion._failSame = function( expected, actual,  message )
{
var formatted = "";
if( message != null )
{
formatted = message + " ";
}
this.fail( String.format( buRRRn.ASTUce.strings.expectedNotSame, formatted ) ); 
}
buRRRn.ASTUce.Assertion._failNotSame = function( expected, actual,  message )
{
var formatted= "";
if( message != null )
{
formatted= message + " ";
}
this.fail( String.format( buRRRn.ASTUce.strings.expectedSame, formatted, expected, actual ) ); 
}
buRRRn.ASTUce.Assertion._failNotEquals = function( expected, actual,  message )
{
if( buRRRn.ASTUce.showObjectSource && (expected != null) && (actual != null) )
{
expected = expected.toSource(); 
actual   = actual.toSource(); 
}
if( buRRRn.ASTUce.invertExpectedActual )
{
var tmp  = expected;
expected = actual;
actual   = tmp;
}
this.fail( buRRRn.ASTUce.Assertion.format( expected, actual, message ) );
}
buRRRn.ASTUce.Assertion.format = function( expected, actual,  message )
{
var formatted = "";
if( (message != null) && (message != "") )
{
formatted = message + " ";
}
return( String.format( buRRRn.ASTUce.strings.expectedButWas, formatted, expected, actual ) ); 
}
buRRRn.ASTUce.AssertionFailedError = function(  message )
{
this.message = message;
this.name = "AssertionFailedError";
}
buRRRn.ASTUce.AssertionFailedError.prototype = new Error();
buRRRn.ASTUce.AssertionFailedError.prototype.constructor = buRRRn.ASTUce.AssertionFailedError;
buRRRn.ASTUce.ComparisonFailure = function( expected, actual,  message )
{
buRRRn.ASTUce.AssertionFailedError.call( this, message );
this.name     = "ComparisonFailure";
this.expected = expected;
this.actual   = actual;
}
buRRRn.ASTUce.ComparisonFailure.prototype = new buRRRn.ASTUce.AssertionFailedError();
buRRRn.ASTUce.ComparisonFailure.prototype.constructor = buRRRn.ASTUce.ComparisonFailure;
buRRRn.ASTUce.ComparisonFailure.prototype.getMessage = function()
{
if( (this.expected == null) || (this.actual == null) )
{
return buRRRn.ASTUce.Assertion.format( this.expected, this.actual, this.message );
}
var expected, actual, end, dots, i, j, k;
expected = "";
actual   = "";
end      = Math.min( this.expected.length, this.actual.length );
dots     = "...";
for( i=0; i<end; i++ )
{
if( this.expected.charAt(i) != this.actual.charAt(i) )
{
break;
}
}
j = this.expected.length - 1;
k = this.actual.length - 1;
for( ; k>=i && j>=i; k--,j-- )
{
if( this.expected.charAt(j) != this.actual.charAt(k) )
{
break;
}
}
if( j<i && k<i )
{
expected = this.expected;
actual   = this.actual;
}
else
{
expected = this.expected.substring( i, j+1 );
actual   = this.actual.substring(   i, k+1 );
if( i<=end && i>0 )
{
expected = dots + expected;
actual   = dots + actual;
}
if( j < this.expected.length-1 )
{
expected = expected + dots;
}
if( k < this.actual.length-1 )
{
actual = actual + dots;
}
}
return buRRRn.ASTUce.Assertion.format( expected, actual, this.message );
}
buRRRn.ASTUce.verbose = true;
buRRRn.ASTUce.showConstructorList = false;
buRRRn.ASTUce.showObjectSource = true;
buRRRn.ASTUce.invertExpectedActual = false;
buRRRn.ASTUce.testPrivateMethods = false;
buRRRn.ASTUce.testMyself = false;
buRRRn.ASTUce.IProtectable = function()
{
}
buRRRn.ASTUce.IProtectable.prototype.protect = function()
{
}
buRRRn.ASTUce.ITest = function()
{
}
buRRRn.ASTUce.ITest.prototype.countTestCases = function()
{
}
buRRRn.ASTUce.ITest.prototype.run = function(  result )
{
}
buRRRn.ASTUce.ITestListener = function()
{
}
buRRRn.ASTUce.ITestListener.prototype.addError = function(  test,  e )
{
}
buRRRn.ASTUce.ITestListener.prototype.addFailure = function(  test,  afe )
{
}
buRRRn.ASTUce.ITestListener.prototype.endTest = function(  test )
{
}
buRRRn.ASTUce.ITestListener.prototype.startTest = function(  test )
{
}
buRRRn.ASTUce.MiniRunner = function(  suiteName )
{
if( suiteName == null )
{
suiteName = "MAIN";
}
this.suite   = new buRRRn.ASTUce.TestSuite( suiteName );
this.result  = new buRRRn.ASTUce.TestResult();
this.printer = new buRRRn.ASTUce.ResultPrinter();
}
buRRRn.ASTUce.MiniRunner.prototype.setUp = function()
{
}
buRRRn.ASTUce.MiniRunner.prototype.run = function()
{
this.setUp();
var time1, time2, runtime;
time1 = new Date();
this.suite.run( this.result );
time2 = new Date();
runtime = time2 - time1;
this.printer.print( this.result, runtime );
}
buRRRn.ASTUce.ResultPrinter = function(  writer )
{
this.writer = trace; 
this.column = 0;
if( (writer != null) && (GetTypeOf( writer ) == "function") ) 
{
this.writer = writer;
}
}
buRRRn.ASTUce.ResultPrinter.prototype.writeLine = function(  message )
{
var writer;
writer = this.getWriter();
writer( message );
}
buRRRn.ASTUce.ResultPrinter.prototype.print = function(  result,  runTime )
{
this.printHeader( runTime );
this.printErrors( result );
this.printFailures( result );
this.printFooter( result );
}
buRRRn.ASTUce.ResultPrinter.prototype.printHeader = function(  runTime )
{
this.writeLine( "" );
this.writeLine( String.format( buRRRn.ASTUce.strings.PrtTime, this.elapsedTimeAsString( runTime ) ) ); 
}
buRRRn.ASTUce.ResultPrinter.prototype.printErrors = function(  result )
{
this.printDefects( result.errors(), result.errorCount(), buRRRn.ASTUce.strings.nameError );
}
buRRRn.ASTUce.ResultPrinter.prototype.printFailures = function(  result )
{
this.printDefects( result.failures(), result.failureCount(), buRRRn.ASTUce.strings.nameFailure );
}
buRRRn.ASTUce.ResultPrinter.prototype.printDefects = function(  booBoos,  count,  type )
{
var i;
if( count == 0 )
{
return;
}
if( count == 1 )
{
this.writeLine( "" );
this.writeLine( String.format( buRRRn.ASTUce.strings.PrtOneDefect, count, type ) ); 
}
else
{
this.writeLine( "" );
this.writeLine( String.format( buRRRn.ASTUce.strings.PrtMoreDefects, count, type ) ); 
}
for( i=0; i<booBoos.length; i++ )
{
this.printDefectHeader( booBoos[i], i );
this.printDefectTrace( booBoos[i] );
}
}
buRRRn.ASTUce.ResultPrinter.prototype.printDefectHeader = function(  booBoo,  count )
{
this.writeLine( count + ") " + booBoo.failedTest() );
}
buRRRn.ASTUce.ResultPrinter.prototype.printDefectTrace = function(  booBoo )
{
this.writeLine( booBoo.thrownException() ); 
this.writeLine( "" );
}
buRRRn.ASTUce.ResultPrinter.prototype.printFooter = function(  result )
{
if( result.wasSuccessful() == true )
{
this.writeLine( "" );
this.writeLine( String.format( buRRRn.ASTUce.strings.PrtOK, result.runCount(), (result.runCount() == 1 ? "": "s") ) ); 
}
else
{
this.writeLine( "" );
this.writeLine( buRRRn.ASTUce.strings.PrtFailure );
this.writeLine( String.format( buRRRn.ASTUce.strings.PrtFailureDetails, result.runCount(), result.failureCount(), result.errorCount() ) ); 
		}
this.writeLine( "" );
}
buRRRn.ASTUce.ResultPrinter.prototype.elapsedTimeAsString = function(  runTime )
{
var dat, ms, s, m, h;
if( GetTypeOf( runTime ) == "number" ) 
{
dat = new Date( runTime );
}
else if( GetTypeOf( runTime ) == "date" ) 
{
dat = runTime;
}
ms = dat.getMilliseconds();
s  = dat.getSeconds();
m  = dat.getMinutes();
h  = dat.getHours() - 1;
return String.format( buRRRn.ASTUce.strings.PrtElapsedTime, h, m, s, ms );
}
buRRRn.ASTUce.ResultPrinter.prototype.getWriter = function()
{
return this.writer
}
buRRRn.ASTUce.ResultPrinter.prototype.addError = function(  test,  e )
{
this.writeLine( "E" );
}
buRRRn.ASTUce.ResultPrinter.prototype.addFailure = function(  test,  afe )
{
this.writeLine( "F" );
}
buRRRn.ASTUce.ResultPrinter.prototype.endTest = function(  test )
{
}
buRRRn.ASTUce.ResultPrinter.prototype.startTest = function(  test )
{
}
if( !buRRRn.ASTUce.samples )
{
buRRRn.ASTUce.samples = {};
}
if( !buRRRn.ASTUce.strings )
{
buRRRn.ASTUce.strings = {};
}
buRRRn.ASTUce.strings.expectedNotSame      = "{0}expected not same";
buRRRn.ASTUce.strings.expectedSame         = "{0}expected same:<{1}> was not:<{2}>";
buRRRn.ASTUce.strings.expectedButWas       = "{0}expected:<{1}> but was:<{2}>";
buRRRn.ASTUce.strings.methodNameNull       = "The method name is null";
buRRRn.ASTUce.strings.methodNameUndef      = "The method name is undefined";
buRRRn.ASTUce.strings.methodNotFound       = "Method \"{0}\" not found";
buRRRn.ASTUce.strings.methodshouldBePublic = "Method \"{0}\" should be public";
buRRRn.ASTUce.strings.objectNotCtor        = "Object \"{0}\" is not a constructor";
buRRRn.ASTUce.strings.ctorNotPublic        = "Constructor \"{0}\" is not public";
buRRRn.ASTUce.strings.noTestsFound         = "No tests found in \"{0}\"";
buRRRn.ASTUce.strings.argTestDoesNotExist  = "the argument \"test\" does not exist in the objects namespace (check your includes!)";
buRRRn.ASTUce.strings.argTestNotATest      = "the argument \"test\" does not inherit from TestCase or TestSuite";
buRRRn.ASTUce.strings.testMethNotPublic    = "Test method \"{0}\" isn't public";
buRRRn.ASTUce.strings.canNotCreateTest     = "Cannot instantiate \"{0}\" test case";
buRRRn.ASTUce.strings.nameError            = "error";
buRRRn.ASTUce.strings.nameFailure          = "failure";
buRRRn.ASTUce.strings.PrtTime              = "Time: {0}";
buRRRn.ASTUce.strings.PrtElapsedTime       = "{0}h:{1}mn:{2}s:{3}ms";
buRRRn.ASTUce.strings.PrtOneDefect         = "There was {0} {1}:";
buRRRn.ASTUce.strings.PrtMoreDefects       = "There were {0} {1}s:";
buRRRn.ASTUce.strings.PrtOK                = "OK ({0} test{1})";
buRRRn.ASTUce.strings.PrtFailure           = "FAILURES!!!";
buRRRn.ASTUce.strings.PrtFailureDetails    = "Tests run: {0},  Failures: {1},  Errors: {2}";
buRRRn.ASTUce.TestCase = function(  name )
{
this._name = name; 
}
buRRRn.ASTUce.TestCase.prototype = buRRRn.ASTUce.Assertion;
buRRRn.ASTUce.TestCase.prototype.constructor = buRRRn.ASTUce.TestCase;
buRRRn.ASTUce.TestCase.prototype.countTestCases = function()
{
return 1;
}
buRRRn.ASTUce.TestCase.prototype.createResult = function()
{
return new buRRRn.ASTUce.TestResult();
}
buRRRn.ASTUce.TestCase.prototype.run = function(  result )
{
if( result == null )
{
result = this.createResult();
}
result.run( this );
return result;
}
buRRRn.ASTUce.TestCase.prototype.runBare = function()
{
this.setUp();
this.runTest();
this.tearDown();
if( this.__e != null )
{
return this.__e;
}
}
buRRRn.ASTUce.TestCase.prototype.runTest = function()
{
var runMethod;
this.assertNotNull( this._name, buRRRn.ASTUce.strings.methodNameNull );
this.assertNotUndefined( this._name, buRRRn.ASTUce.strings.methodNameUndef );
if( this.hasProperty( this._name ) )
{
runMethod = this[this._name];
}
else
{
this.fail( String.format( buRRRn.ASTUce.strings.methodNotFound, this._name ) );
return;
}
if( this._name.startsWith( "_" ) && (buRRRn.ASTUce.testPrivateMethods != true) )
{
this.fail( String.format( buRRRn.ASTUce.strings.methodshouldBePublic, this._name ) );
return;
}
runMethod.call( this );
}
buRRRn.ASTUce.TestCase.prototype.setUp = function()
{
}
buRRRn.ASTUce.TestCase.prototype.tearDown = function()
{
}
buRRRn.ASTUce.TestCase.prototype.toString = function()
{
return( this.getConstructorName() + "( " + this.getName() + " )" ); 
}
buRRRn.ASTUce.TestCase.prototype.getName = function()
{
if( this._name == undefined )
{
this._name = GetObjectPath( this ); 
}
return this._name;
}
buRRRn.ASTUce.TestCase.prototype.setName = function(  name )
{
this._name = name;
}
buRRRn.ASTUce.TestFailure = function(  failedTest,  thrownException )
{
this._failedTest = failedTest;
this._thrownException = thrownException;
}
buRRRn.ASTUce.TestFailure.prototype.failedTest = function()
{
return this._failedTest;
}
buRRRn.ASTUce.TestFailure.prototype.thrownException = function()
{
return this._thrownException;
}
buRRRn.ASTUce.TestFailure.prototype.exceptionMessage = function()
{
return this.thrownException().getMessage();
}
buRRRn.ASTUce.TestFailure.prototype.isFailure = function()
{
return( this.thrownException() instanceof buRRRn.ASTUce.AssertionFailedError );
}
buRRRn.ASTUce.TestFailure.prototype.toString = function()
{
return( this.failedTest() + ": " + this.exceptionMessage() );
}
buRRRn.ASTUce.TestFailure.prototype.trace = function()
{
trace( this.toSource() ); 
}
buRRRn.ASTUce.TestResult = function()
{
this._failures  = [];
this._errors    = [];
this._listeners = [];
this._runTests  = 0;
this._stop      = false;
}
buRRRn.ASTUce.TestResult.prototype.addError = function(  test,  e )
{
var i, listeners;
this._errors.push( new buRRRn.ASTUce.TestFailure( test, e ) );
listeners = this.cloneListeners();
for( i=0; i<listeners.length; i++ )
{
listeners[i].addError( test, e );
}
}
buRRRn.ASTUce.TestResult.prototype.addFailure = function(  test,  afe )
{
var i, listeners;
this._failures.push( new buRRRn.ASTUce.TestFailure( test, afe ) );
listeners = this.cloneListeners();
for( i=0; i<listeners.length; i++ )
{
listeners[i].addFailure( test, afe );
}
}
buRRRn.ASTUce.TestResult.prototype.addListener = function(  listener )
{
this._listeners.push( listener );
}
buRRRn.ASTUce.TestResult.prototype.removeListener = function(  listener )
{
var index;
index = this._listeners.indexOf( listener );
if( index > -1 )
{
this._listeners.splice( index, 1 );
}
}
buRRRn.ASTUce.TestResult.prototype.cloneListeners = function()
{
return this._listeners.clone(); 
}
buRRRn.ASTUce.TestResult.prototype.endTest = function(  test )
{
var listeners, i;
listeners = this.cloneListeners();
for( i=0; i<listeners.length; i++ )
{
listeners[i].endTest( test );
}
}
buRRRn.ASTUce.TestResult.prototype.errorCount = function()
{
return this._errors.length;
}
buRRRn.ASTUce.TestResult.prototype.errors = function()
{
return this._errors;
}
buRRRn.ASTUce.TestResult.prototype.failureCount = function()
{
return this._failures.length;
}
buRRRn.ASTUce.TestResult.prototype.failures = function()
{
return this._failures;
}
buRRRn.ASTUce.TestResult.prototype.run = function(  test )
{
var p;
this.startTest( test );
p = new buRRRn.ASTUce.IProtectable();
p.protect = function()
{
return test.runBare();
}
this.runProtected( test, p );
this.endTest( test );
}
buRRRn.ASTUce.TestResult.prototype.runProtected = function(  test,  p )
{
var e;
e = p.protect();
if( e instanceof buRRRn.ASTUce.AssertionFailedError )
{
this.addFailure( test, e );
}
else if( e instanceof Error )
{
this.addError( test, e );
}
}
buRRRn.ASTUce.TestResult.prototype.runCount = function()
{
return this._runTests;
}
buRRRn.ASTUce.TestResult.prototype.shouldStop = function()
{
return this._stop;
}
buRRRn.ASTUce.TestResult.prototype.startTest = function(  test )
{
var count, listeners, i;
count = test.countTestCases();
this._runTests += count;
listeners = this.cloneListeners();
for( i=0; i<listeners.length; i++ )
{
listeners[i].startTest( test );
}
}
buRRRn.ASTUce.TestResult.prototype.stop = function()
{
this._stop = true;
}
buRRRn.ASTUce.TestResult.prototype.wasSuccessful = function()
{
return( (this.failureCount() == 0) && (this.errorCount() == 0) );
}
buRRRn.ASTUce.TestSuite = function(  theConstructor,  name,  simpleTrace )
{
var ctorName, member;
if( simpleTrace == null )
{
simpleTrace = false;
}
this.simpleTrace = simpleTrace;
this._tests       = [];
this._name        = "Unknown";
if( (theConstructor == null) && (name == null) )
{
return;
}
if( GetTypeOf( theConstructor ) == "string" )
{
this.setName( theConstructor );
return;
}
if( theConstructor.prototype == null )
{
this.addTest( this._warning( String.format( buRRRn.ASTUce.strings.objectNotCtor, GetObjectPath( theConstructor ) ) ) ); 
return;
}
else
{
ctorName = theConstructor.prototype.getConstructorName(); 
}
if( ctorName.startsWith( "_" ) ) 
{
this.addTest( this._warning( String.format( buRRRn.ASTUce.strings.ctorNotPublic, ctorName ) ) );
return;
}
if( name == null )
{
this.setName( ctorName );
}
else
{
this.setName( name );
}
for( member in theConstructor.prototype )
{
if( typeof( theConstructor.prototype[member] ) == "function" )
{
this._addTestMethod( member, theConstructor );
}
}
if( this.testCount() == 0 )
{
this.addTest( this._warning( String.format( buRRRn.ASTUce.strings.noTestsFound, ctorName ) ) ); 
}
}
buRRRn.ASTUce.TestSuite.prototype.addTest = function(  test )
{
if( test === undefined )
{
this.addTest( this._warning( buRRRn.ASTUce.strings.argTestDoesNotExist ) );
return;
}
if( (test instanceof buRRRn.ASTUce.TestCase) || (test instanceof buRRRn.ASTUce.TestSuite) )
{
this._tests.push( test );
}
else
{
this.addTest( this._warning( buRRRn.ASTUce.strings.argTestNotATest ) );
}
}
buRRRn.ASTUce.TestSuite.prototype.addTestSuite = function(  testConstructor )
{
this.addTest( new buRRRn.ASTUce.TestSuite( testConstructor ) );
}
buRRRn.ASTUce.TestSuite.prototype._addTestMethod = function(  method,  theConstructor )
{
var test;
if( !this._isTestMethod( method ) )
{
return;
}
if( !this._isPublicTestMethod( method ) && (buRRRn.ASTUce.testPrivateMethods != true) )
{
this.addTest( this._warning( String.format( buRRRn.ASTUce.strings.testMethNotPublic, method ) ) ); 
return;
}
this.addTest( buRRRn.ASTUce.TestSuite.createTest( theConstructor, method ) );
}
buRRRn.ASTUce.TestSuite.createTest = function(  theConstructor,  name )
{
var test;
if( theConstructor == null )
{
return( this._warning( String.format( buRRRn.ASTUce.strings.canNotCreateTest, name ) ) );
}
if( theConstructor.prototype == null )
{
this.addTest( this._warning( String.format( buRRRn.ASTUce.strings.objectNotCtor, GetObjectPath( theConstructor ) ) ) );
return;
}
var path = GetObjectPath( theConstructor ); 
var tmp  = eval( path );
var test = new tmp( name );
return test;
}
buRRRn.ASTUce.TestSuite.prototype.countTestCases = function()
{
var count, tests, i;
count = 0;
tests = this.tests();
for( i=0; i<tests.length; i++ )
{
count += tests[i].countTestCases();
}
return count;
}
buRRRn.ASTUce.TestSuite.prototype._isPublicTestMethod = function(  method )
{
return( this._isTestMethod( method ) && !method.startsWith( "_" ) ); 
}
buRRRn.ASTUce.TestSuite.prototype._isTestMethod = function(  method )
{
method = method.toLowerCase();
return( method.startsWith( "test" ) || method.startsWith( "_test" ) ); 
}
buRRRn.ASTUce.TestSuite.prototype.run = function(  result )
{
var test, tests, i;
tests = this.tests();
for( i=0; i< tests.length; i++ )
{
if( result.shouldStop() )
{
break;
}
test = tests[i];
this.runTest( test, result );
}
}
buRRRn.ASTUce.TestSuite.prototype.runTest = function(  test,  result )
{
test.run( result );
}
buRRRn.ASTUce.TestSuite.prototype.testAt = function(  index )
{
return this._tests[index];
}
buRRRn.ASTUce.TestSuite.prototype.testCount = function()
{
return this._tests.length;
}
buRRRn.ASTUce.TestSuite.prototype.tests = function()
{
return this._tests;
}
buRRRn.ASTUce.TestSuite.prototype.toString = function(  increment )
{
var str, CRLF, TAB, SPC, i, j, tests, count;
str   = "";
CRLF  = "\n";
TAB   = "\t";
SPC   = TAB;
if( increment == null )
{
increment = 0;
}
else
{
for( j=0; j<increment; j++ )
{
SPC += TAB;
}
TAB = SPC;
}
tests = this.tests();
count = this.testCount();
str  += this.getName();
if( count > 0 )
{
str += CRLF + TAB + "{" + CRLF;
if( this.simpleTrace )
{
str += TAB + this.countTestCases() + " Tests ..." + CRLF;
}
else
{
for( i=0; i<count; i++ )
{
if( tests[i] instanceof buRRRn.ASTUce.TestSuite )
{
increment++;
}
str += TAB + tests[i].toString( increment ) + CRLF;
if( tests[i] instanceof buRRRn.ASTUce.TestSuite )
{
increment--;
}
}
}
str += TAB + "}";
}
return str;
}
buRRRn.ASTUce.TestSuite.prototype.setName = function(  name )
{
this._name = name;
}
buRRRn.ASTUce.TestSuite.prototype.getName = function()
{
if( this._name == undefined )
{
this._name = GetObjectPath( this ); 
}
return this._name;
}
buRRRn.ASTUce.TestSuite.prototype._warning = function(  message )
{
var TC;
TC = new buRRRn.ASTUce.TestCase( "warning" );
TC.runTest = function()
{
this.fail( message );
}
return TC;
}
buRRRn.ASTUce.samples.IMoney = function()
{
}
buRRRn.ASTUce.samples.IMoney.prototype.plus = function(  m )
{
}
buRRRn.ASTUce.samples.IMoney.prototype.addMoney = function(  m )
{
}
buRRRn.ASTUce.samples.IMoney.prototype.addMoneyBag = function(  mb )
{
}
buRRRn.ASTUce.samples.IMoney.prototype.isZero = function()
{
}
buRRRn.ASTUce.samples.IMoney.prototype.multiply = function(  factor )
{
}
buRRRn.ASTUce.samples.IMoney.prototype.negate = function()
{
}
buRRRn.ASTUce.samples.IMoney.prototype.minus = function(  m )
{
}
buRRRn.ASTUce.samples.IMoney.prototype.appendTo = function(  mb )
{
}
buRRRn.ASTUce.samples.Money = function(  amount,  currency )
{
this._amount = amount;
this._currency = currency;
}
buRRRn.ASTUce.samples.Money.prototype.toString = function()
{
return "["+this.amount()+this.currency()+"]";
}
buRRRn.ASTUce.samples.Money.prototype.equals = function(  obj )
{
if( obj instanceof buRRRn.ASTUce.samples.Money )
{
if( this.isZero() )
{
return obj.isZero();
}
return( (this.currency() == obj.currency()) && (this.amount() == obj.amount()) );
}
return false;
}
buRRRn.ASTUce.samples.Money.prototype.plus = function(  m )
{
return m.addMoney( this );
}
buRRRn.ASTUce.samples.Money.prototype.addMoney = function(  m )
{
if( m.currency() == this.currency() )
{
return new buRRRn.ASTUce.samples.Money( this.amount() + m.amount() , this.currency() );
}
return buRRRn.ASTUce.samples.MoneyBag.create( this, m );
}
buRRRn.ASTUce.samples.Money.prototype.addMoneyBag = function(  mb )
{
return mb.addMoney( this );
}
buRRRn.ASTUce.samples.Money.prototype.currency = function()
{
return this._currency;
}
buRRRn.ASTUce.samples.Money.prototype.amount = function()
{
return this._amount;
}
buRRRn.ASTUce.samples.Money.prototype.isZero = function()
{
return( this.amount() == 0 );
}
buRRRn.ASTUce.samples.Money.prototype.multiply = function(  factor )
{
return( new buRRRn.ASTUce.samples.Money( (this.amount()*factor), this.currency() ) );
}
buRRRn.ASTUce.samples.Money.prototype.negate = function()
{
return( new buRRRn.ASTUce.samples.Money( -this.amount(), this.currency() ) );
}
buRRRn.ASTUce.samples.Money.prototype.minus = function(  m )
{
return( this.plus( m.negate() ) );
}
buRRRn.ASTUce.samples.Money.prototype.appendTo = function(  mb )
{
mb.appendMoney( this );
}
buRRRn.ASTUce.samples.MoneyBag = function()
{
this._monies = [];
}
buRRRn.ASTUce.samples.MoneyBag.create = function(  m1,  m2 )
{
var result;
result = new buRRRn.ASTUce.samples.MoneyBag();
m1.appendTo( result );
m2.appendTo( result );
return result.simplify();
}
buRRRn.ASTUce.samples.MoneyBag.prototype.plus = function(  m )
{
return m.addMoneyBag( this );
}
buRRRn.ASTUce.samples.MoneyBag.prototype.addMoney = function(  m )
{
return buRRRn.ASTUce.samples.MoneyBag.create( m, this );
}
buRRRn.ASTUce.samples.MoneyBag.prototype.addMoneyBag = function(  mb )
{
return buRRRn.ASTUce.samples.MoneyBag.create( mb, this );
}
buRRRn.ASTUce.samples.MoneyBag.prototype.appendBag = function(  aBag )
{
var i;
for( i=0; i<aBag._monies.length; i++ )
{
this.appendMoney( aBag._monies[i] );
}
}
buRRRn.ASTUce.samples.MoneyBag.prototype.appendMoney = function(  aMoney )
{
var old, sum;
if( aMoney.isZero() )
{
return;
}
old = this.findMoney( aMoney.currency() );
if( old == null )
{
this._monies.push( aMoney );
return;
}
this._monies.splice( this._monies.indexOf( old ) , 1 );
sum = old.plus( aMoney );
if( sum.isZero() )
{
return;
}
this._monies.push( sum );
}
buRRRn.ASTUce.samples.MoneyBag.prototype.equals = function(  obj )
{
var i, aMoneyBag, m;
if( obj instanceof buRRRn.ASTUce.samples.MoneyBag )
{
aMoneyBag = obj;
if( this.isZero() )
{
return( aMoneyBag.isZero() );
}
if( aMoneyBag._monies.length != this._monies.length )
{
return false;
}
for( i=0; i<this._monies.length; i++ )
{
m = this._monies[i];
if( !aMoneyBag.contains( m ) )
{
return false;
}
}
return true;
}
return false;
}
buRRRn.ASTUce.samples.MoneyBag.prototype.findMoney = function(  currency )
{
var i, m;
for( i=0; i<this._monies.length; i++ )
{
m = this._monies[i];
if( m.currency().equals( currency ) )
{
return m;
}
}
return null;
}
buRRRn.ASTUce.samples.MoneyBag.prototype.contains = function(  m )
{
var found;
found = this.findMoney( m.currency() );
if( found == null )
{
return false;
}
return( found.amount() == m.amount() );
}
buRRRn.ASTUce.samples.MoneyBag.prototype.isZero = function()
{
return( this._monies.length == 0 );
}
buRRRn.ASTUce.samples.MoneyBag.prototype.multiply = function(  factor )
{
var result, i, m;
result = new buRRRn.ASTUce.samples.MoneyBag();
if( factor != 0 )
{
for( i=0; i<this._monies.length; i++ )
{
m = this._monies[i];
result.appendMoney( m.multiply( factor ) );
}
}
return result;
}
buRRRn.ASTUce.samples.MoneyBag.prototype.negate = function()
{
var result, i, m;
result = new buRRRn.ASTUce.samples.MoneyBag();
for( i=0; i<this._monies.length; i++ )
{
m = this._monies[i];
result.appendMoney( m.negate() );
}
return result;
}
buRRRn.ASTUce.samples.MoneyBag.prototype.simplify = function()
{
if( this._monies.length == 1 )
{
return this._monies[0];
}
return this;
}
buRRRn.ASTUce.samples.MoneyBag.prototype.minus = function(  m )
{
return this.plus( m.negate() );
}
buRRRn.ASTUce.samples.MoneyBag.prototype.toString = function()
{
var str, i;
str = "";
for( i=0; i<this._monies.length; i++ )
{
str += this._monies[i].toString() ;
}
return "{" + str + "}";
}
buRRRn.ASTUce.samples.MoneyBag.prototype.appendTo = function(  mb )
{
mb.appendBag( this );
}
/* generated by Milk v1.0 */
